package com.recsmile.sgs.ui.components;

import com.recsmile.sgs.entity.cards.equips.Equipment;

import javax.swing.*;
import java.awt.*;

/**
 * Created by Administrator on 2016/8/26.
 */
public class EquipmentGui extends JButton{

    private static final long serialVersionUID = -7493423607741338720L;

    public static final int WIDTH = EquipmentRackGui.WIDTH;
    public static final int HEIGHT = EquipmentRackGui.HEIGHT / 4;

    private Equipment equipment;

    public EquipmentGui(int verticalLocation) {
        setSize(WIDTH, HEIGHT);
        setLocation(0, verticalLocation);
        setFont(new Font(Font.MONOSPACED, Font.BOLD, 25));
        this.setHorizontalAlignment(JButton.CENTER);
        setEnabled(false);
        equipment = null;
    }

    /**
     * Set an equipment
     *
     * @param equipment
     */
    public synchronized void setEquipment(Equipment equipment) {
        this.equipment = equipment;
        if (equipment == null)
            setText("");
        else
            this.setText(equipment.getName());
        // repaint();
    }

    //@Override
    public synchronized Equipment getEquipment() {
        return equipment;
    }
}
